package com.jy.appmarket.network.engine;

import java.util.Map;

import com.jy.appmarket.network.resultdata.PageResult;

import android.content.Context;

public class TopsNetEngine extends BaseNetEngine {
	private int mPage;
	private TopType mType;
	private long mDataVersion;

	public enum TopType {
		TYPE_DOWNLOAD, TYPE_RISE, TYPE_PRAISE
	}

    public TopsNetEngine(TopType type, long dataVersion, int page) {
		mResultData = new PageResult();
		mDataVersion = dataVersion;
		mType = type;
		mPage = page;
	}

	@Override
	protected String getCommand() {
		return "tops";
	}

	@Override
	protected void getParams(Context context, Map<String, String> custParams) {
		custParams.put("type", getType());
		if (mPage != 1) {
			custParams.put("pageNo", String.valueOf(mPage));
		}
		if (mDataVersion != 0) {
			custParams.put("type", getType());
		}
	}

	private String getType() {
		if (mType == null) {
			return "download";
		}
		if (mType == TopType.TYPE_RISE) {
			return "rise";
		}
		if (mType == TopType.TYPE_PRAISE) {
			return "praise";
		}
		return "download";
	}
}
